package cn.lupin.controller;

import cn.lupin.enums.VideoStatusEnum;
import cn.lupin.pojo.Videos;
import cn.lupin.service.VideoService;
import cn.lupin.utils.LaughJSONResult;
import cn.lupin.utils.PagedResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping("/forbidVideo")
    @ResponseBody
    public LaughJSONResult forbidVideo(String videoId) {
        videoService.updateVideoStatus(videoId, VideoStatusEnum.FORBID.value);
        return LaughJSONResult.ok();
    }

    @GetMapping("/showList")
    public String showList() {
        return "video/videoList";
    }

    @PostMapping("/list")
    @ResponseBody
    public PagedResult list(Videos video, Integer page) {
        return videoService.queryVideoList(video, page == null ? 1 : page, 10);
    }
}
